package playn.game.core;

import static playn.core.PlayN.graphics;
import playn.core.Image;
import playn.core.Surface;
import playn.core.SurfaceLayer;
import tiled.simple.core.Map;
import tiled.simple.core.Renderer;

public class MapLayer implements Renderer {

	public SurfaceLayer layer;
	
	public MapLayer(Map map){
		
		int w=map.getWidth()*map.getTileWidth();
		int h=map.getHeight()*map.getTileHeight();
		
		layer=graphics().createSurfaceLayer(w,h);

		map.render(this);
	}
	
	public void putImage(String source, int sx, int sy, int sw, int sh, int dx,int dy, int dw, int dh) {
		Image image=null;
		
		if(!Game.images.containsKey(source)){
			System.out.println("you have to load "+source+" image from loader using imagesCache");
		} else {
			image=Game.images.get(source);
		}
		
		Surface surface = layer.surface();
		surface.drawImage(image, dx, dy, dw, dh, sx, sy, sw, sh);

}
}
